home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / include / gsl / gsl_multimin.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-04-20  |  5.2 KB  |  181 lines

  1. /* multimin/gsl_multimin.h
  2.  * 
  3.  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Fabrice Rossi
  4.  * 
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or (at
  8.  * your option) any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful, but
  11.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #ifndef __GSL_MULTIMIN_H__
  21. #define __GSL_MULTIMIN_H__
  22.  
  23. #include <stdlib.h>
  24. #include <gsl/gsl_math.h>
  25. #include <gsl/gsl_vector.h>
  26. #include <gsl/gsl_matrix.h>
  27. #include <gsl/gsl_min.h>
  28.  
  29. #undef __BEGIN_DECLS
  30. #undef __END_DECLS
  31. #ifdef __cplusplus
  32. # define __BEGIN_DECLS extern "C" {
  33. # define __END_DECLS }
  34. #else
  35. # define __BEGIN_DECLS /* empty */
  36. # define __END_DECLS /* empty */
  37. #endif
  38.  
  39. __BEGIN_DECLS
  40.  
  41. /* Definition of an arbitrary real-valued function with gsl_vector input and */
  42. /* parameters */
  43. struct gsl_multimin_function_struct 
  44. {
  45.   double (* f) (const gsl_vector * x, void * params);
  46.   size_t n;
  47.   void * params;
  48. };
  49.  
  50. typedef struct gsl_multimin_function_struct gsl_multimin_function;
  51.  
  52. #define GSL_MULTIMIN_FN_EVAL(F,x) (*((F)->f))(x,(F)->params)
  53.  
  54. /* Definition of an arbitrary differentiable real-valued function */
  55. /* with gsl_vector input and parameters */
  56. struct gsl_multimin_function_fdf_struct 
  57. {
  58.   double (* f) (const gsl_vector  * x, void * params);
  59.   void (* df) (const gsl_vector * x, void * params,gsl_vector * df);
  60.   void (* fdf) (const gsl_vector * x, void * params,double *f,gsl_vector * df);
  61.   size_t n;
  62.   void * params;
  63. };
  64.  
  65. typedef struct gsl_multimin_function_fdf_struct gsl_multimin_function_fdf;
  66.  
  67. #define GSL_MULTIMIN_FN_EVAL_F(F,x) (*((F)->f))(x,(F)->params)
  68. #define GSL_MULTIMIN_FN_EVAL_DF(F,x,g) (*((F)->df))(x,(F)->params,(g))
  69. #define GSL_MULTIMIN_FN_EVAL_F_DF(F,x,y,g) (*((F)->fdf))(x,(F)->params,(y),(g))
  70.  
  71. int gsl_multimin_diff (const gsl_multimin_function * f,
  72.                        const gsl_vector * x, gsl_vector * g);
  73.  
  74. /* minimisation of differentiable functions */
  75.  
  76. typedef struct 
  77. {
  78.   const char *name;
  79.   size_t size;
  80.   int (*alloc) (void *state, size_t n);
  81.   int (*set) (void *state, gsl_multimin_function_fdf * fdf,
  82.               const gsl_vector * x, double * f, 
  83.               gsl_vector * gradient, double step_size, double tol);
  84.   int (*iterate) (void *state,gsl_multimin_function_fdf * fdf, 
  85.                   gsl_vector * x, double * f, 
  86.                   gsl_vector * gradient, gsl_vector * dx);
  87.   int (*restart) (void *state);
  88.   void (*free) (void *state);
  89. }
  90. gsl_multimin_fdfminimizer_type;
  91.  
  92. typedef struct 
  93. {
  94.   /* multi dimensional part */
  95.   const gsl_multimin_fdfminimizer_type *type;
  96.   gsl_multimin_function_fdf *fdf;
  97.  
  98.   double f;
  99.   gsl_vector * x;
  100.   gsl_vector * gradient;
  101.   gsl_vector * dx;
  102.  
  103.   void *state;
  104. }
  105. gsl_multimin_fdfminimizer;
  106.  
  107. gsl_multimin_fdfminimizer *
  108. gsl_multimin_fdfminimizer_alloc(const gsl_multimin_fdfminimizer_type *T,
  109.                                 size_t n);
  110.  
  111. int 
  112. gsl_multimin_fdfminimizer_set (gsl_multimin_fdfminimizer * s,
  113.                                gsl_multimin_function_fdf *fdf,
  114.                                const gsl_vector * x,
  115.                                double step_size, double tol);
  116.  
  117. void
  118. gsl_multimin_fdfminimizer_free(gsl_multimin_fdfminimizer *s);
  119.  
  120. const char * 
  121. gsl_multimin_fdfminimizer_name (const gsl_multimin_fdfminimizer * s);
  122.  
  123. int
  124. gsl_multimin_fdfminimizer_iterate(gsl_multimin_fdfminimizer *s);
  125.  
  126. int
  127. gsl_multimin_fdfminimizer_restart(gsl_multimin_fdfminimizer *s);
  128.  
  129. int
  130. gsl_multimin_test_gradient(const gsl_vector * g,double epsabs);
  131.  
  132. gsl_vector * 
  133. gsl_multimin_fdfminimizer_x (gsl_multimin_fdfminimizer * s);
  134.  
  135. gsl_vector * 
  136. gsl_multimin_fdfminimizer_dx (gsl_multimin_fdfminimizer * s);
  137.  
  138. gsl_vector * 
  139. gsl_multimin_fdfminimizer_gradient (gsl_multimin_fdfminimizer * s);
  140.  
  141. double 
  142. gsl_multimin_fdfminimizer_minimum (gsl_multimin_fdfminimizer * s);
  143.  
  144. #ifdef GSL_EXPORTS
  145. __declspec(dllexport) const 
  146. #elif defined(GSL_IMPORTS)
  147. __declspec(dllimport) const 
  148. #else
  149. extern const 
  150. #endif
  151. gsl_multimin_fdfminimizer_type *gsl_multimin_fdfminimizer_steepest_descent;
  152. #ifdef GSL_EXPORTS
  153. __declspec(dllexport) const 
  154. #elif defined(GSL_IMPORTS)
  155. __declspec(dllimport) const 
  156. #else
  157. extern const 
  158. #endif
  159. gsl_multimin_fdfminimizer_type *gsl_multimin_fdfminimizer_conjugate_pr;
  160. #ifdef GSL_EXPORTS
  161. __declspec(dllexport) const 
  162. #elif defined(GSL_IMPORTS)
  163. __declspec(dllimport) const 
  164. #else
  165. extern const 
  166. #endif
  167. gsl_multimin_fdfminimizer_type *gsl_multimin_fdfminimizer_conjugate_fr;
  168. #ifdef GSL_EXPORTS
  169. __declspec(dllexport) const 
  170. #elif defined(GSL_IMPORTS)
  171. __declspec(dllimport) const 
  172. #else
  173. extern const 
  174. #endif
  175. gsl_multimin_fdfminimizer_type *gsl_multimin_fdfminimizer_vector_bfgs;
  176.  
  177.  
  178. __END_DECLS
  179.  
  180. #endif /* __GSL_MULTIMIN_H__ */
  181.